package com.gxu.sjjg;

import java.awt.*;
import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.*;
import javax.swing.plaf.*;

public class Fuctionframe {
    public Fuctionframe(){
        initComponents();
        fuction.setVisible(true);//①要加这句使窗口可见，否则就只是一个默认窗口，啥也没有。②要放在上一句的后面，因为initComponents()会创建窗口对象，否则frame1和pannel1是null
        panel1.setVisible(true);
        //setDefaultCloseOperation(DISPOSE_ON_CLOSE);//设置前台关闭后程序结束
    }

    private void help(ActionEvent e) {
        new Help();
    }

//    界面代码
    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        fuction = new JFrame();
        panel1 = new JPanel();
        add = new JButton();
        fenxi = new JButton();
        modify = new JButton();
        manageset = new JButton();
        label1 = new JLabel();
        find = new JButton();
        manageset2 = new JButton();
        bgp = new JLabel();

        //======== fuction ========
        {
            fuction.setTitle("\u83dc\u5355");
            fuction.setResizable(false);
            fuction.setVisible(true);
            var fuctionContentPane = fuction.getContentPane();
            fuctionContentPane.setLayout(null);

            //======== panel1 ========
            {
                panel1.setLayout(null);

                //---- add ----
                add.setText("\u5f55\u5165\u6210\u7ee9");
                add.setOpaque(false);
                add.setContentAreaFilled(false);
                panel1.add(add);
                add.setBounds(185, 80, 95, add.getPreferredSize().height);

                //---- fenxi ----
                fenxi.setText("\u5206\u6790\u6210\u7ee9");
                fenxi.setContentAreaFilled(false);
                panel1.add(fenxi);
                fenxi.setBounds(185, 125, 95, 30);

                //---- modify ----
                modify.setText("\u66f4\u6b63\u6210\u7ee9");
                modify.setContentAreaFilled(false);
                panel1.add(modify);
                modify.setBounds(185, 175, 95, 30);

                //---- manageset ----
                manageset.setText("\u7ba1\u7406\u5458\u8bbe\u7f6e");
                manageset.setContentAreaFilled(false);
                panel1.add(manageset);
                manageset.setBounds(180, 270, 110, manageset.getPreferredSize().height);

                //---- label1 ----
                label1.setText("\u6210\u7ee9\u5206\u6790\u7cfb\u7edf");
                label1.setFont(new Font("\u534e\u6587\u6977\u4f53", Font.BOLD, 26));
                label1.setBackground(new Color(238, 238, 238));
                label1.setForeground(Color.black);
                panel1.add(label1);
                label1.setBounds(140, 30, 180, 40);

                //---- find ----
                find.setText("\u67e5\u8be2\u6210\u7ee9");
                find.setContentAreaFilled(false);
                panel1.add(find);
                find.setBounds(185, 220, 95, 30);

                //---- manageset2 ----
                manageset2.setText("\u5e2e\u52a9");
                manageset2.setContentAreaFilled(false);
                manageset2.addActionListener(e -> help(e));
                panel1.add(manageset2);
                manageset2.setBounds(205, 315, 60, 28);

                //---- bgp ----
                bgp.setIcon(new ImageIcon(getClass().getResource("/myimage/loginimg.jpg")));
                panel1.add(bgp);
                bgp.setBounds(0, 0, 490, 380);
            }
            fuctionContentPane.add(panel1);
            panel1.setBounds(0, -30, 490, 380);

            fuctionContentPane.setPreferredSize(new Dimension(490, 380));
            fuction.pack();
            fuction.setLocationRelativeTo(fuction.getOwner());
        }
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
        add.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                    new AddGrade();
            }
        });
        manageset.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new AddManager();
            }
        });
        find.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    new FindGrade();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
        });
        fenxi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new Analysefuction();
            }
        });
        modify.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new AlterFuction();
            }
        });
    }
    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JFrame fuction;
    private JPanel panel1;
    private JButton add;
    private JButton fenxi;
    private JButton modify;
    private JButton manageset;
    private JLabel label1;
    private JButton find;
    private JButton manageset2;
    private JLabel bgp;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
